home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / FILEXIST.ZIP / FILEXIST.BAS
Encoding:
BASIC Source File  |  1995-11-21  |  855 b   |  37 lines

  1. Option Explicit
  2.  
  3. Function FileExists% (filename$)
  4.  
  5. ' Description
  6. '     Checks 'filename$' to find wether the filename given
  7. '     exists.
  8. '
  9. ' Parameters
  10. '     Name              Type     Value
  11. '     -------------------------------------------------------------
  12. '     filename$         String   The filename to be checked
  13. '
  14. ' Returns
  15. '     True if the file exists
  16. '     False if the file does not exist
  17. '
  18. ' Last updated by Jens Balchen 21.11.95
  19.  
  20.  
  21. Dim f%
  22.  
  23.    ' Trap any errors that may occur
  24.    On Error Resume Next
  25.  
  26.    ' Get a free file handle to avoid using a file handle already in use
  27.    f% = FreeFile
  28.    ' Open the file for reading
  29.    Open filename$ For Input As #f%
  30.    ' Close it
  31.    Close #f%
  32.    ' If there was an error, Err will be <> 0. In that case, we return False
  33.    FileExists% = Not (Err <> 0)
  34.  
  35. End Function
  36.  
  37.